<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-IsFood__isfood">
      <el-form
        :inline="true"
        :model="dataForm"
        @keyup.enter.native="getDataList()"
      >
        <el-form-item>
          <el-input
            v-model="dataForm.name"
            placeholder="请输入商户名称"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="dataForm.creditCode"
            placeholder="请输入统一社会代码"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="dataForm.legalPerson"
            placeholder="请输入企业法人"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="dataForm.idCard"
            placeholder="请输入法人身份证号"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="dataForm.phone"
            placeholder="请输入联系方式"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-select
            v-model="dataForm.islandId"
            placeholder="请选择区域"
            clearable
          >
            <el-option
              v-for="item in scenicOptions"
              :key="item.id"
              :label="item.scenicName"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-select
            v-model="dataForm.status"
            placeholder="请选择状态"
            clearable
          >
            <el-option
              v-for="item in status"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="" @click="getDataList()">{{
            $t("query")
          }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button  v-if="$hasPermission('merchant:info:info')" type="primary" @click="exportHandle()">导出</el-button>
        </el-form-item>
      </el-form>
      <el-table
        v-loading="dataListLoading"
        :data="dataList"
        border
        @selection-change="dataListSelectionChangeHandle"
        @sort-change="dataListSortChangeHandle"
        style="width: 100%"
      >
        <el-table-column
          type="selection"
          header-align="center"
          align="center"
          width="50"
        ></el-table-column>
        <el-table-column
          prop="creditCode"
          label="统一社会信用代码"
          header-align="center"
          align="center"
          min-width="150"
        ></el-table-column>
        <el-table-column
          prop="name"
          label="商户名称"
          sortable="custom"
          header-align="center"
          align="center"
          :show-overflow-tooltip="true"
          min-width="120"
        ></el-table-column>
        <el-table-column
          prop="merchantCategory"
          label="商户类型"
          header-align="center"
          align="center"
          min-width="120"
        >
          <template slot-scope="scope">
            {{ $getDictLabel("MerchantCategory", scope.row.merchantCategory) }}
          </template>
        </el-table-column>
        <el-table-column
          prop="legalPerson"
          label="企业法人"
          header-align="center"
          align="center"
          width="180"
        ></el-table-column>
        <el-table-column
          prop="idCard"
          label="法人身份证号"
          header-align="center"
          align="center"
          width="180"
        ></el-table-column>
        <el-table-column
          prop="islandName"
          label="区域"
          header-align="center"
          align="center"
          :show-overflow-tooltip="true"
          min-width="120"
        >
        </el-table-column>
        <el-table-column
          prop="status"
          label="状态"
          header-align="center"
          align="center"
          width="180"
        >
          <template slot-scope="scope">
            {{ scope.row.status | delStatus }}
          </template>
        </el-table-column>
        <el-table-column
          prop="createDate"
          label="创建时间"
          header-align="center"
          align="center"
          :show-overflow-tooltip="true"
          min-width="120"
        ></el-table-column>
        <el-table-column
          :label="$t('handle')"
          fixed="right"
          header-align="center"
          align="center"
          min-width="180"
        >
          <template slot-scope="scope">
            <el-button
              type="text"
              size="small"
               v-if="$hasPermission('merchant:info:info')"
              @click="lookDetail(scope.row.id)"
              >查看</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle"
      >
      </el-pagination>
      <!-- 详情 -->
      <look-detail v-if="lookDetailVisible" ref="lookDetail"></look-detail>
      <!-- 菜品 -->
      <!-- <food-suggest v-if="addOrUpdateVisible2" ref="addOrUpdate2" @refreshDataList="getDataList"></food-suggest> -->
    </div>
  </el-card>
</template>

<script>
var that;
import mixinViewModule from "@/mixins/view-module";
import lookDetail from "./detail";
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      disabled: false,
      addOrUpdateVisible2: "",
      mixinViewModuleOptions: {
        getDataListURL: "/scenic/merchant/info/page",
        getDataListIsPage: true,
        deleteURL: "/scenic/merchant/info",
        deleteIsBatch: true,
        exportURL: "/scenic/merchant/info/export",
        // getDataListURL: "/scenic/merchant/info/page",
        // getDataListIsPage: true,
        // exportURL: "/sys/isfood/export",
        // deleteURL: "/sys/isfood",
        // deleteIsBatch: true,
      },
      scenicOptions:[],
      status: [
        {
          label: "审核未通过",
          value: 4,
        },
        {
          label: "审核通过",
          value: 1,
        },
        {
          label: "待审核",
          value: 2,
        },
      ],
      dataForm: {
        name: "",
        creditCode: "",
        merchantCategory: 4,
        legalPerson: "",
        idCard: "",
        phone: "",
        islandId: "",
        status: "",
      },
    };
  },
  filters: {
    delStatus(val) {
      if (val) {
        let d = that.status.filter((item) => item.value == val);
        if (d.length != 0) {
          return d[0].label;
        }
      }
    },
  },
  components: {
    lookDetail,
  },
  created(){
    that=this;
    this.getScenicOptions();
  },
  methods: {
     getScenicOptions() {
      this.$http
        .get("scenic/isscenic/selectScenicList", {})
        .then(({
          data: res
        }) => {
          if (res.msg == "success") {
            this.scenicOptions = res.data;
          }
        });
    },
    viewHandle(row) {
      this.addOrUpdateVisible = true;
      this.disabled = true;
      this.$nextTick(() => {
        this.$refs.addOrUpdate.visible = true;
        this.$refs.addOrUpdate.dataForm.id = row.id;
        this.$refs.addOrUpdate.dataForm.details = true;
        this.$refs.addOrUpdate.init();
      });
    },
    foodSuggest(row) {
      this.addOrUpdateVisible2 = true;
      this.$nextTick(() => {
        this.$refs.addOrUpdate2.visible = true;
        this.$refs.addOrUpdate2.dataForm.id = row.id;
        this.$refs.addOrUpdate2.init();
      });
    },
  },
};
</script>
